require 'mongo'

client = Mongo::Client.new([ '127.0.0.1:27017' ], :database => 'learning')
collection = client[:users]

$dimension1 = %w[综合型 序列型]
$dimension2 = %w[视觉型 言语型]
$dimension3 = %W[感悟型 直觉型]
$dimension4 = %W[活跃性 沉思型]


def init_style
  style = Array.new
  style.push($dimension1.sample)
  style.push($dimension2.sample)
  style.push($dimension3.sample)
  style.push($dimension4.sample)
  style
end

collection.find(:role => 'user').projection(:username => 1).each do |document|
  collection.update_one({'username' => document["username"]}, '$set'=>{'style' => init_style})
end

